<template>
	<div>
		<Row>
			<Col class="p-1" :xs="24" :sm="24" :md="12" :lg="8" :xl="6" :xxl="4">
			<Input class="w-100" v-model="searchKey.name" placeholder="请输入会员类型名称" />
			</Col>
		</Row>
		<Row>
			<div class="w-100 d-flex justify-content-between align-items-center ">
				<Button class="m-1" type="error" shape="circle" @click="newviptype" icon="md-add">新增</Button>
				<Button class="m-1" type="primary" shape="circle" @click="searchs" icon="ios-search">查询</Button>
			</div>
		</Row>
		<div class="mt-1">
			<Table border :class="'m-1'" :columns="tableInfo.columnInfo" :data="tableInfo.data">
				<template slot-scope="{ row, index }" slot="headimg">
					<div>
						<img style="width: 40px; height: 40px;" :src="row.headimg" />
					</div>
				</template>
				<template slot-scope="{ row, index }" slot="statu">
					<div>
						<span class="text-danger" v-if="row.statu == '0'">下架</span>
						<span class="text-primary" v-else>上架</span>
					</div>
				</template>
				<template slot-scope="{ row, index }" slot="action">
					<Button type="primary" size="small" class="text-xss mr-2" @click="show(row.viptypeid)">详细</Button>
				</template>
			</Table>
		</div>
		<div>
			<Page class="text-right mt-3" :page-size="tableInfo.pageSize" @on-change="pageSearch"
				:total="tableInfo.total" />
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				searchKey: {
					viptypeid: "",
					name: "",
					minuts: "",
					price: "",
					statu: "",
					
					headimg: "",
					from: "",
				
				},
				tableInfo: {
					currentPage: 1,
					pageSize: 10,
					total: 0,
					columnInfo: [
						{
							title: "会员类型编号",
							key: "viptypeid",
						},
						{
							title: "会员类型名称",
							key: "name",
						},
						{
							title: "会员分钟",
							key: "minuts",
						},
						{
							title: "价格",
							key: "price",
						},
						{
							title: "状态",
							slot: "statu",
						},
						{
							title: "操作",
							slot: 'action',
							width: 150
						}
					],
					data: []
				}
			}
		},
		props: {
			params: {
				type: Object,
				default: undefined,
			}
		},
		methods: {
			init: function() {
				this.tableInfo.currentPage = 0;
				this.search();
			},
			newviptype: function() {
				this.$router.detail.open({
					name: "hyt_new",
					
				});
			},
			show: function(viptypeid) {
				this.$router.detail.open({
					name: "hyt_detail",
					params: {
						viptypeid
					}
				});
			},
			remove: function(viptypeid) {
				this.message.confirm({
					title: "删除提示",
					content: "即将删除，确定吗？",
					onOk: () => {
						this.http.delete({
							url: "/hyt/info",
							param: {
								viptypeid
							}
						}).then(data => {
							this.search();
						});
					},
					onCancel: () => {
						this.message.info('操作已取消');
					}
				});
			},
			searchs: function() {
				this.tableInfo.currentPage = 1;
				this.search();
			},
			search: function() {
				this.http.get({
					url: "/hyt/page",
					param: {
						// 传一个当前页
						current: this.tableInfo.currentPage,
						size:this.tableInfo.pageSize,
						
					}
				}).then(data => {
					this.tableInfo.data = data.records;
					this.tableInfo.currentPage = data.current;
					this.tableInfo.total = data.total;
					this.tableInfo.pageSize = data.size;
				});
			},
			pageSearch: function(changedPage) {
				this.tableInfo.currentPage = changedPage;
				this.search();
			}
		},
		created: function() {
			this.init();
		}
	}
</script>

<style>
</style>
